package com.atguigui.leetcode;

/**
 * 2042.检查句子中的数字是否递增
 * Project: leetcode
 * Package: com.atguigui.leetcode
 * Version: 1.0
 * <p>
 * Created by WJX on 2023/1/3 8:52
 */
public class P2042CheckIfNumbersAreAscendingInASentence {

    public static void main(String[] args) {
        Solution solution = new P2042CheckIfNumbersAreAscendingInASentence().new Solution();
        // TO TEST
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public boolean areNumbersAscending(String s) {

            int flag = -1;
            String[] split = s.split(" ");
            for (String str : split) {
                if (Character.isDigit(str.charAt(0))) {
                    if (Integer.valueOf(str) > flag) {
                        flag = Integer.valueOf(str);
                    } else {
                        return false;
                    }
                }
            }

            return true;
        }
    }
}
